﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace EHR18
{
    public class PropertyChangeBase : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged(string PropertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(PropertyName));
            }
        }
    }
    public static class PropertyChangeBaseEx
    {
        public static void OnPropertyChanged<T, TProperty>(this T PropertyChangeBase, Expression<Func<T, TProperty>> PropertyName)
       where T : PropertyChangeBase
        {
            var _PropertyName = PropertyName.Body as MemberExpression;
            if (PropertyName != null)
            {
                PropertyChangeBase.OnPropertyChanged(_PropertyName.Member.Name);
            }
        }
    }

}
